<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--导入easyui样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
 $(function(){
	 //配置数据表格
		 $('#dg').datagrid({    
			      url:'find',
			      columns:[[
		            {field:'ck',width:100,checkbox:true},
		            {field:'cid',title:'cid',width:100,},
			        {field:'cname',title:'cname',width:100,},
			        
			        ]],
			        toolbar:[{
			        	iconCls : 'icon-add',
						text : '增加课程',
						handler : function() {
							var stus = $('#dg').datagrid('getSelections');
							$("#log").dialog('open');
							$("#cid").val(stus[0].cid);
							$("#cname").val(stus[0].cname);
							$("#myfrom").form({
								url : 'choose',
								success : function(data) {
									if(data==1){
										 $.messager.alert({
								    			title:'信息提示',
								    			msg:'增加成功',
								    			timeout:1000,
								    			showType:'slide'
								    		});
										/*  $('#dg').datagrid('reload'); */
									}
									else{
										$.messager.alert({
							    			title:'信息提示',
							    			msg:'选课失败，该课程已选',
							    			timeout:1000,
							    			showType:'slide'
							    		});
									}
									
								}
							})
							$("#btn1").linkbutton({
								onClick : function() {
									 $("#myfrom").submit(); 
									$("#log").dialog('close');
									$('#dg').datagrid('reload');
								}
							});
							 
						}
			        }]
			        
			       	
	 
 })

 
 
 
 
 })

</script>
<body>
<table id="dg"></table>
<div id="log" class="easyui-dialog" closed="true">
		<form id="myfrom" method="post">
		        <!-- 学生id：<input id="sid" name="sid" type="text" style="width: 300px">
			<br> -->
		        课程id：<input id="cid" name="cid" type="text" style="width: 300px">
			<br>            
			课程名字：<input id="cname" name="cname" type="text" style="width: 300px">
			<br>		 
            <a id="btn1" class="easyui-linkbutton">确认</a> 
            <a id="btn2" class="easyui-linkbutton">取消</a>
        </form>
        
</div>
				

</body>
</html>